import subprocess

# p = subprocess.run(['ping www.baidu.com -c 2'])
p = subprocess.run(["ping", "www.baidu.com", "-c", "2"])
print("run ret: ", p)

""" 
run ret:  CompletedProcess(args=['ping', 'www.baidu.com', '-c', '2'], returncode=0)
"""